import sys
import os
sys.path.append("..")

import getopt

from CoreSim.Simulator import *
from TestFlowScheduler import *
from Topology.FatTree import *
from Routing.ECMP_FatTree import *

if __name__ == "__main__":

    K = 10
    numHosts = 10
    numLinks = 10
    numSwitches = 64
    link_sh_Bw = 1e10
    link_ss_Bw = 1e10

    load = 0.6
    randomSeed = 1
    FLOW_LAUNCH_END_TIME = 0.01
    cdfFileName = "cdf/DCTCP_CDF.txt"
    flowsFileName = "flows_%sToRs_%sHosts_%sLinks_%sLoad.txt"%(numSwitches,numHosts,numLinks,load)
    flow_type = 'CDF'
    
    compile_cmd = "g++ ./Input/fct.cc -o ./Input/fct -std=c++11"
    os.system(compile_cmd)
    run_cmd = "./Input/fct numHosts " + str(numHosts) + " numLinks " + str(numLinks) \
        + " numSwitches " + str(numSwitches) + " link_sh_Bw " + str(link_sh_Bw) \
        + " link_ss_Bw " + str(link_ss_Bw) + " load " + str(load) + " randomSeed " \
        + str(randomSeed) + " cdfFileName " + inDir + cdfFileName + " flowsFileName " \
        + inDir + flowsFileName + " FLOW_LAUNCH_END_TIME " + str(FLOW_LAUNCH_END_TIME) 
    os.system(run_cmd)

    sim = Simulator()
    testTopo = FatTree(K=K)
    testTopo.CreateTopology()
    sim.AssignTopology(topo=testTopo, cap=1.0 * Gb)
    sim.AssignRoutingEngine(Routing=ECMP)
    sim.AssignScheduler(FlowScheduler=TestFlowScheduler, args=(K, fileName))
    sim.Run()